package com.cheyunkeji.er.adapter;

import android.os.Parcelable;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

import androidx.viewpager.widget.PagerAdapter;

public class HcPageAdapter extends PagerAdapter {
    List<View> views;

    public HcPageAdapter(List<View> v) {
        super();
        views = v;
    }

    @Override
    public void destroyItem(ViewGroup vg, int pos, Object arg2) {
        if (pos < views.size()) {
            vg.removeView(views.get(pos));
        }
    }

    @Override
    public void finishUpdate(ViewGroup vg) {

    }

    @Override
    public int getCount() {

        if (null != views)
            return views.size();
        else
            return 0;
    }

    @Override
    public Object instantiateItem(ViewGroup vg, int pos) {
        vg.addView(views.get(pos));
        return views.get(pos);
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;
    }

    @Override
    public void restoreState(Parcelable arg0, ClassLoader arg1) {

    }

    @Override
    public Parcelable saveState() {
        return null;
    }

    @Override
    public void startUpdate(ViewGroup vg) {
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

}
